from typing import List

from sqlalchemy.orm import Session

from app.models import BroadcastPresetsLibrary
from app.schemas.broadcast_presets_library import BroadcastPresetsLibraryCreate, BroadcastPresetsLibraryUpdate
from app.crud.base import CRUDBase

# 创建 BroadcastPresetsLibrary 的 CRUD 对象
class CRUDBroadcastPresetsLibrary(CRUDBase[BroadcastPresetsLibrary, BroadcastPresetsLibraryCreate, BroadcastPresetsLibraryUpdate]):
    def get_unique_categories(self, db: Session) -> List[str]:
        """
        获取不重复的分类名称列表。
        """
        result = db.query(BroadcastPresetsLibrary.category_name).distinct().all()
        return [category[0] for category in result]

# 实例化 CRUD 对象，以便在路由（route）中使用
broadcast_presets_library = CRUDBroadcastPresetsLibrary(BroadcastPresetsLibrary)
